package com.zbest.zpay.acctrans.share.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zbest.zpay.acctrans.common.exception.AccTransRuntimeException;
import com.zbest.zpay.acctrans.dal.mapper.TransJnlMapper;
import com.zbest.zpay.acctrans.dal.model.TransJnl;
import com.zbest.zpay.acctrans.enums.biz.AcctransBizCode;
import com.zbest.zpay.acctrans.share.TransJnlService;

/**
 * Created by wenfeihu on 16/5/25.
 */
@Service("transJnlService")
public class TransJnlServiceImpl implements TransJnlService {

    @Autowired
    private TransJnlMapper transJnlMapper;

    @Override
    public void register(TransJnl transJnl) {
        int retCod = transJnlMapper.insert(transJnl);
        if (retCod != 1) {
            throw new AccTransRuntimeException(AcctransBizCode.ACT_TRANS_JNL_UPD_FAIL,
                    "更新记账流水表失败");
        }
    }

    @Override
    public void updateState(String state, String jrnNo) {
        int retCod = transJnlMapper.updateState(state, jrnNo);
        if (retCod != 1) {
            throw new AccTransRuntimeException(AcctransBizCode.ACT_TRANS_JNL_UPD_FAIL,
                    "更新记账流水表失败");
        }
    }
}
